#!/usr/bin/env python

import sys
sys.path.insert(0,'/home/mike/projects/non-mike/ReportLab/trunk/reportlab/build/lib.linux-i686-2.2/')

from reportlab.pdfgen import canvas
from reportlab.lib import pagesizes
from reportlab.lib.units import inch, cm
from reportlab.platypus import Frame, Paragraph
from reportlab.lib.styles import getSampleStyleSheet

(width,height) = pagesizes.landscape(pagesizes.LETTER)
left_margin = cm

def drawPageFrame(canv):
    #print canv.getAvailableFonts()
    canv.setFont('Times-Italic',32)
    canv.drawString(cm,height-cm,'Activist Network Event Listings')
    canv.setFont('Helvetica',16)
    foo = 'http://calgary.activist.ca'
    canv.drawString(width-cm-canv.stringWidth(foo,'Helvetica',16),height-cm,foo)
    canv.line(0.1*cm,height-1.25*cm,width-0.1*cm,height-1.25*cm)

    fr = Frame(cm,height-2*cm,width/2.0,height-2.5*cm)
    canv.setFont("Times-Bold", 12)
    event = Paragraph("this is some text.", getSampleStyleSheet()['Normal'])
    fr.add(event,canv)
    print dir(canv)
    #canv.drawText(tx)

    canv.showPage()

canv = canvas.Canvas('activist-test.pdf', invariant=1, pagesize=pagesizes.landscape(pagesizes.LETTER))
canv.setPageCompression(1)
drawPageFrame(canv)
#canv.save()
open('activist-test.pdf','wb').write(canv.getpdfdata())


